package com.day18.Copy;

import java.io.*;

public class CopyAviDemo {
    public static void main(String[] args) throws IOException {
        long startTime=System.currentTimeMillis();
        method4();
        long endTime=System.currentTimeMillis();
        System.out.println("复制文件耗时："+(endTime-startTime)+"ms");
    }
    public static void method4() throws IOException{
        BufferedInputStream bis=new BufferedInputStream(new FileInputStream("myByteStream\\fos.avi"));
        BufferedOutputStream bos=new BufferedOutputStream(new FileOutputStream("myByteStream\\fos.avi"));
        byte[] bys=new byte[1024];
        int len;
        while((len=bis.read(bys))!=-1){
            bos.write(bys,0,len);
        }
        bos.close();
        bis.close();
    }
    public static void method1() throws IOException{
        FileInputStream fis=new FileInputStream("myByteStream\\fos.avi");
        FileOutputStream fos=new FileOutputStream("myByteStream\\fos.avi");
        int by;
        while((by=fis.read())!=-1){
            fos.write(by);
        }
        fos.close();
        fis.close();
    }
}
